package com.sk.cardeal.adapter;

import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.cardeal.R;
import com.sk.cardeal.entity.ByKindList;
import com.sk.cardeal.entity.ByPartsEntity;

import java.util.List;

/**
 * Created by sk on 2018/4/17.
 */

public class NewFixByAdapter extends BaseQuickAdapter<ByKindList.ResultListBean,BaseViewHolder> {

    public NewFixByAdapter(int layoutResId, @Nullable List<ByKindList.ResultListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ByKindList.ResultListBean item) {

        helper.setText(R.id.content,item.getPartsName())
                .addOnClickListener(R.id.right);
        LinearLayout ll = helper.getView(R.id.parts_ll);
        ll.removeAllViews();
        for(ByPartsEntity entity : item.getCarPartsList()){
            View view = LayoutInflater.from(mContext).inflate(R.layout.item_child_fix_by_parts,ll,false);
            TextView tv_name = view.findViewById(R.id.tv_name);
            TextView tv_num = view.findViewById(R.id.tv_num);
            TextView tv_price = view.findViewById(R.id.tv_price);
            tv_name.setText(entity.getPartsName());
            tv_num.setText("×"+entity.getSelectCount());
            tv_price.setText("￥"+entity.getPrice());
            ll.addView(view);
        }

    }
}
